package com.loan.common.pdf;

import com.itextpdf.text.*;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @PACKAGE_NAME: com.loan.web.utils
 * @CLASSNAME: CreatePdfUtilTwo
 * @DEACRIPTION:
 * @AUTHOR: GuoChen
 * @DATE: 2024/7/2
 * @WEEK: 周二
 **/
@Slf4j
public class CreatePdfUtilTwo {

    static DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");

    public static void download() throws IOException {
        //要下载的数据查询数据部分我去掉了有需要自己根据业务取
        // FumigationDowloadVO fumigationDowloadVO = new FumigationDowloadVO();

        File file = new File("E:\\QuickStart\\DeskTop\\GCHTemp\\test\\pdftest.pdf");
        OutputStream outputStream = new FileOutputStream(file);

        // 定义全局的字体静态变量
        Font titlefont;
        Font headfont;
        Font keyfont = null;
        Font textfont = null;
        Font content = null;
        // 最大宽度
        try {
            // 不同字体（这里定义为同一种字体：包含不同字号、不同style）
            // "C:/WINDOWS/FONTS/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED
            BaseFont bfChinese = BaseFont.createFont("C:/WINDOWS/FONTS/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            titlefont = new Font(bfChinese, 16, Font.BOLD);
            headfont = new Font(bfChinese, 14, Font.BOLD);
            keyfont = new Font(bfChinese, 10, Font.BOLD);
            textfont = new Font(bfChinese, 15, Font.NORMAL);
            content = new Font(bfChinese, 10, Font.NORMAL);

        } catch (Exception e) {
            e.printStackTrace();
        }
        BaseFont bf;
        Font font = null;
        try {
            //创建字体
            bf = BaseFont.createFont("C:/WINDOWS/FONTS/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            //使用字体并给出颜色
            font = new Font(bf, 16, Font.NORMAL, BaseColor.BLACK);
        } catch (Exception e) {
            e.printStackTrace();
        }

        Document document = new Document(new RectangleReadOnly(595.0F, 842.0F));
        //设置页边距  60:左边距，60：右边距，72：上边距，72：下边距
        document.setMargins(60, 60, 72, 72);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, outputStream);
            //添加页码
            writer.setPageEvent(new PdfPageUtil());
            //打开生成的pdf文件
            document.open();
            //设置内容
            Paragraph paragraph = new Paragraph("中国农业银行账户活期交易明细清单", font);
            paragraph.setAlignment(1);
            //引用字体
            document.add(paragraph);

            // 设置表格的列宽和列数
            float[] widths = {25f, 25f, 25f, 25f, 25f, 25f};
            PdfPTable table = new PdfPTable(widths);
            table.setSpacingBefore(20f);
            // 设置表格宽度为100%
            table.setWidthPercentage(100.0F);
            table.setHeaderRows(1);
            table.getDefaultCell().setHorizontalAlignment(1);
            PdfPCell cell = null;
            //第一行
            cell = new PdfPCell(new Paragraph("熏蒸备案编码", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(30);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("0001编码", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("熏蒸备案时间", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("2024-07-02", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("申请备案单位", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("燃源网络技术", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            //第二行
            cell = new PdfPCell(new Paragraph("熏蒸作业库点", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(30);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("凯利国际中心", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("负责人", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("郭晨", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("联系电话", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("15517528729", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);
            //第三行
            cell = new PdfPCell(new Paragraph("单据状态", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(30);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("审核中", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("审核时间", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("2024-07-02 14:30:28", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("审核人", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("测试陈", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table.addCell(cell);

            // 设置表格的列宽和列数
            float[] widths2 = {25f, 25f, 25f, 25f, 25f, 25f};
            PdfPTable table2 = new PdfPTable(widths2);
            table2.setSpacingBefore(20f);
            // 设置表格宽度为100%
            table2.setWidthPercentage(100.0F);
            table2.setHeaderRows(1);
            table2.getDefaultCell().setHorizontalAlignment(1);

            //人员列表-第四行
            cell = new PdfPCell(new Paragraph("姓名", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("职务", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("职业资格", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("身体状况", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("熏蒸任务分工", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table2.addCell(cell);

            cell = new PdfPCell(new Paragraph("是否外包", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            // cell.setBorder(PdfPCell.NO_BORDER);
            table2.addCell(cell);

            for (int i = 0; i < 24; i++) {
                PdfPCell cell1 = new PdfPCell(new Paragraph("测试000" + i, content));
                //单元格对齐方式
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                // cell1.setBorder(PdfPCell.NO_BORDER);
                // cell1.setFixedHeight(20);
                table2.addCell(cell1);
            }
            //人员列表数据-第五行
            /*if(fumigationDowloadVO.getProples().size() > 0){
                for (RecordFumigationPeople prople : fumigationDowloadVO.getProples()) {
                    PdfPCell cell1 = new PdfPCell(new Paragraph(prople.getXm(), content));
                    PdfPCell cell2 = new PdfPCell(new Paragraph(prople.getZw(), content));
                    PdfPCell cell3 = new PdfPCell(new Paragraph(prople.getZyzg(), content));
                    PdfPCell cell4 = new PdfPCell(new Paragraph(prople.getStzk(), content));
                    PdfPCell cell5 = new PdfPCell(new Paragraph(prople.getXzrwfg(), content));
                    PdfPCell cell6 = new PdfPCell(new Paragraph(prople.getSfwb(), content));

                    //单元格对齐方式
                    cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    cell1.setFixedHeight(20);
                    //单元格垂直对齐方式
                    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    cell6.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    table2.addCell(cell1);
                    table2.addCell(cell2);
                    table2.addCell(cell3);
                    table2.addCell(cell4);
                    table2.addCell(cell5);
                    table2.addCell(cell6);
                }
            }*/

            // 设置表格的列宽和列数
            float[] widths3 = {25f, 25f, 25f, 25f, 25f};
            PdfPTable table3 = new PdfPTable(widths3);
            table3.setSpacingBefore(20f);
            // 设置表格宽度为100%
            table3.setWidthPercentage(100.0F);
            table3.setHeaderRows(1);
            table3.getDefaultCell().setHorizontalAlignment(1);

            //实施储粮信息
            cell = new PdfPCell(new Paragraph("仓房", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setFixedHeight(20);
            table3.addCell(cell);

            cell = new PdfPCell(new Paragraph("货位", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table3.addCell(cell);

            cell = new PdfPCell(new Paragraph("粮食品种", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table3.addCell(cell);

            cell = new PdfPCell(new Paragraph("计划熏蒸开始时间", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table3.addCell(cell);

            cell = new PdfPCell(new Paragraph("计划熏蒸结束时间", content));
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            table3.addCell(cell);

            for (int i = 0; i < 15; i++) {
                PdfPCell cell1 = new PdfPCell(new Paragraph("测试000" + i, content));
                //单元格对齐方式
                cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                // cell1.setFixedHeight(20);
                table3.addCell(cell1);
            }


            /*if(fumigationDowloadVO.getDtls().size() > 0){
                for (RecordFumigationDtlVO dtl : fumigationDowloadVO.getDtls()) {
                    PdfPCell cell1 = new PdfPCell(new Paragraph(dtl.getCfmc(), content));
                    PdfPCell cell2 = new PdfPCell(new Paragraph(dtl.getHwmc(), content));
                    PdfPCell cell3 = new PdfPCell(new Paragraph(dtl.getLspzmc(), content));
                    PdfPCell cell4 = new PdfPCell(new Paragraph(CheckVerifyUtil.dateToString4(dtl.getJhxzksrq()), content));
                    PdfPCell cell5 = new PdfPCell(new Paragraph(CheckVerifyUtil.dateToString4(dtl.getJhxzjsrq()), content));
                    //设置居中
                    cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    cell1.setFixedHeight(20);

                    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);

                    table3.addCell(cell1);
                    table3.addCell(cell2);
                    table3.addCell(cell3);
                    table3.addCell(cell4);
                    table3.addCell(cell5);

                }
            }*/

            document.add(new Paragraph("\n"));
            Paragraph hm = new Paragraph("户名：燃源陈", content);
            Paragraph zh = new Paragraph("账户：23654586963245521", content);
            Paragraph bz = new Paragraph("币种：人民币", content);
            Paragraph chbs = new Paragraph("钞汇标识：本币", content);
            Paragraph qzrq = new Paragraph("起止日期：20230521-202040520", content);
            Paragraph dzlsh = new Paragraph("电子流水号：2405201013036489094", content);

            PdfPTable tb = new PdfPTable(2);
            tb.setWidthPercentage(100);
//            tb.addCell(getCellValue(tb, hm, null, null));
//            tb.addCell(getCellValue(tb, zh, null, Element.ALIGN_RIGHT));
//            tb.addCell(getCellValue(tb, bz, null, null));
//            tb.addCell(getCellValue(tb, chbs, null, Element.ALIGN_RIGHT));
//            tb.addCell(getCellValue(tb, qzrq, null, null));
//            tb.addCell(getCellValue(tb, dzlsh, null, Element.ALIGN_RIGHT));
            document.add(tb);


            // document.add(new Paragraph("▋ 基本信息", content));
            /*Phrase phrase = new Phrase();
            phrase.add(hmpgh);
            phrase.add(pgh);
            document.add(phrase);*/

            /*document.add(new Paragraph("\n"));
            // document.add(new Paragraph("▋ 基本信息", content));
            document.add(new Paragraph("币种：人民币", content));
            document.add(new Paragraph("钞汇标识：本币", content));

            document.add(new Paragraph("\n"));
            // document.add(new Paragraph("▋ 基本信息", content));
            document.add(new Paragraph("起止日期：20230521-02040520", content));
            document.add(new Paragraph("电子流水号：2405201013036489094", content));
            document.add(new Paragraph("\n"));


            document.add(table);*/

            document.add(new Paragraph("\n"));
            document.add(new Paragraph("▋ 人员基本信息", content));
            document.add(new Paragraph("\n"));

            document.add(table2);

            document.add(new Paragraph("\n"));
            document.add(new Paragraph("▋ 熏蒸作业储粮粮情", content));
            document.add(new Paragraph("\n"));

            document.add(table3);
            //关闭文档
            document.close();


        } catch (DocumentException e) {
            e.printStackTrace();
            log.error("导出pdf失败:{}", e);
        }
    }


    public static void createPdfFile() throws IOException {
        // 生成的PDF文件地址
        File file = new File("E:\\QuickStart\\DeskTop\\GCHTemp\\test\\pdftest.pdf");
        OutputStream outputStream = new FileOutputStream(file);

        // 定义全局的字体静态变量
        Font titlefont;
        Font headfont;
        Font keyfont = null;
        Font textfont = null;
        Font content = null;
        Font cellContentFont = null;
        // 最大宽度
        try {
            // 不同字体（这里定义为同一种字体：包含不同字号、不同style）
            // "C:/WINDOWS/FONTS/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED
            BaseFont bfChinese = BaseFont.createFont("C:/WINDOWS/FONTS/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            titlefont = new Font(bfChinese, 16, Font.BOLD);
            headfont = new Font(bfChinese, 14, Font.BOLD);
            keyfont = new Font(bfChinese, 10, Font.BOLD);
            textfont = new Font(bfChinese, 15, Font.NORMAL);
            content = new Font(bfChinese, 10, Font.NORMAL);
            cellContentFont = new Font(bfChinese, 8, Font.NORMAL);

        } catch (Exception e) {
            log.error("字体设置失败：{}", e.getMessage());
            log.error(e.getMessage(), e);
        }
        BaseFont bf;
        Font font = null;
        try {
            //创建字体
            bf = BaseFont.createFont("C:/WINDOWS/FONTS/SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            //使用字体并给出颜色
            font = new Font(bf, 14, Font.NORMAL, BaseColor.BLACK);
        } catch (Exception e) {
            log.error("字体设置失败：{}", e.getMessage());
            log.error(e.getMessage(), e);
        }

        // 设置PDF大小
        Document document = new Document(new RectangleReadOnly(595.0F, 842.0F)); // A4纸张
        //设置页边距  60:左边距，60：右边距，72：上边距，72：下边距
        document.setMargins(60, 60, 72, 72);
        try {
            PdfWriter writer = PdfWriter.getInstance(document, outputStream);
            //添加页码
            writer.setPageEvent(new PdfPageUtil());
            //打开生成的pdf文件
            document.open();
            //设置内容
            Paragraph paragraph = new Paragraph("中国农业银行账户活期交易明细清单", font);
            paragraph.setAlignment(Element.ALIGN_CENTER); // 居中显示
            //引用内容
            document.add(paragraph);
            
            document.add(new Paragraph("\n"));
            PdfPTable tb = new PdfPTable(2);
            tb.setWidthPercentage(100);
            getCellValue(tb, "户名：燃源陈", cellContentFont, null, null);
            getCellValue(tb, "账户：23654586963245521", cellContentFont, null, Element.ALIGN_RIGHT);
            getCellValue(tb, "币种：人民币", cellContentFont, null, null);
            getCellValue(tb, "钞汇标识：本币", cellContentFont, null, Element.ALIGN_RIGHT);
            getCellValue(tb, "起止日期：20230521-202040520", cellContentFont, null, null);
            getCellValue(tb, "电子流水号：2405201013036489094", cellContentFont, null, Element.ALIGN_RIGHT);
            document.add(tb);
            
            // 添加图片到PDF文件中
            PDFUtil.addImg(document, "E:\\QuickStart\\DeskTop\\GCHTemp\\test\\abc_logo.png", 50f, 50f, 460f, 700f);

            // 设置表格的列宽和列数
            float[] widths3 = {10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 20f};
            PdfPTable table3 = new PdfPTable(widths3);
            table3.setSpacingBefore(20f);
            // 设置表格宽度为100%
            table3.setWidthPercentage(100.0F);
            table3.setHeaderRows(1);
            table3.getDefaultCell().setHorizontalAlignment(1);

            // 明细标题
            getCellTitleValue(table3, "交易日期", cellContentFont, null, null);
            getCellTitleValue(table3, "交易时间", cellContentFont, null, null);
            getCellTitleValue(table3, "交易摘要", cellContentFont, null, null);
            getCellTitleValue(table3, "交易金额", cellContentFont, null, null);
            getCellTitleValue(table3, "本次余额", cellContentFont, null, null);
            getCellTitleValue(table3, "对手信息", cellContentFont, null, null);
            getCellTitleValue(table3, "日志号", cellContentFont, null, null);
            getCellTitleValue(table3, "交易渠道", cellContentFont, null, null);
            getCellTitleValue(table3, "交易附言", cellContentFont, null, null);

            for (int i = 0; i < 270; i++) {
                String title = "测试生成PDF-000" + i;
                getCellValue(table3, title, cellContentFont, null, null);
            }

            document.add(table3);
            //关闭文档
            document.close();
        } catch (DocumentException e) {
            log.error("生成PDF文件失败: {}", e.getMessage());
            log.error(e.getMessage(), e);
        }
    }
    
    public static void getCellTitleValue(PdfPTable table, String title, Font font, Integer align, Integer borderValue) {
        /*//隐藏上边框
        cell.disableBorderSide(1);
        //隐藏下边框
        cell.disableBorderSide(2);
        //隐藏上、下边框
        cell.disableBorderSide(3);
        //隐藏左边框
        cell.disableBorderSide(4);
        //隐藏左、上边框
        cell.disableBorderSide(5);
        //隐藏左、下边框
        cell.disableBorderSide(6);
        //隐藏左、上、下边框
        cell.disableBorderSide(7);
        //隐藏右边框
        cell.disableBorderSide(8);
        //隐藏右、上边框
        cell.disableBorderSide(9);
        //隐藏右、下边框
        cell.disableBorderSide(10);
        //隐藏右、上、下边框
        cell.disableBorderSide(11);
        //隐藏左、右边框
        cell.disableBorderSide(12);//左右没了
        //隐藏上、左、右边框
        cell.disableBorderSide(13);//只剩下
        //隐藏下、左、右边框
        cell.disableBorderSide(14);//只剩上
        //隐藏全部
        cell.disableBorderSide(15);//全没了*/
        PdfPCell cell = new PdfPCell(new Paragraph(title, font));
        cell.setFixedHeight(20); // 设置高度
        cell.setHorizontalAlignment(align == null ? 0 : align); // 设置对齐方式 默认水平左对齐
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直对齐
        cell.disableBorderSide(borderValue == null ? 12 : borderValue); // 设置边框信息 默认只显示上下
        table.addCell(cell);
    }

    public static void getCellValue(PdfPTable table, String title, Font font, Integer border, Integer align) {
        PdfPCell cell = new PdfPCell(new Paragraph(title, font));
        cell.setBorder(border == null ? 0 : border); // 设置边框 默认无边框
        cell.setHorizontalAlignment(align == null ? 0 : align); // 设置对齐方式 默认水平左对齐
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 垂直对齐
        table.addCell(cell);
    }

    public static String randomHireday2() {
        int startYear = 2022;
        int endYear = 2023;
        int year = (int) (Math.random() * (endYear - startYear + 1)) + startYear;    //随机年
        int month = (int) (Math.random() * 12) + 1;                                //随机月
        Calendar c = Calendar.getInstance();                //创建Calendar对象
        c.set(year, month, 0);                                //设定日期
        int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);        //获取对应年月有几天
        int day = (int) (Math.random() * dayOfMonth + 1);        //产生随机日
        String hireday =(year + "-" + month + "-" + day);    //通过valueOf方法生成Date对象
        return hireday;
    }

    public static String generateRandomDate(LocalDate startInclusive, LocalDate endExclusive) {
        long startEpochDay = startInclusive.toEpochDay();
        long endEpochDay = endExclusive.toEpochDay();

        long randomDay = startEpochDay + (long) (new Random().nextDouble() * (endEpochDay - startEpochDay));
        LocalDate randomDate = LocalDate.ofEpochDay(randomDay);
        String dateStr = dtf.format(randomDate);
        log.info(dateStr);
        return dateStr;
    }

    public static String getRandomTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("HHmmss");
        // 获取当前时间
        Calendar calendar = Calendar.getInstance();

        // 随机数生成器
        Random random = new Random();
        int min = 6;
        int max = 22;

        // 随机设置时分秒
        calendar.set(Calendar.HOUR_OF_DAY, random.nextInt(max - min + 1) + min); // 0到23点
        calendar.set(Calendar.MINUTE, random.nextInt(60)); // 0到59分
        calendar.set(Calendar.SECOND, random.nextInt(60)); // 0到59秒

        // 输出随机的时间
        Date time = calendar.getTime();
        String timeStr = sdf.format(time);
        log.info(timeStr);
        return timeStr;
    }


    public static void main(String[] args) throws IOException {

        // createPdfFile();
    }



}
